# coding=utf-8

import random
# 设置Client
# client.region_provider.add_endpoint("cr", "cn-beijing", "cr.cn-beijing.aliyuncs.com")
# apiClient = client.AcsClient('LTAILPtWDD74MNzv', 'ivWRuqRoCJAAnnUUSvoHNGWZJwAIGc', 'cn-beijing')
# # 获取所有的镜像列表并解析
# # request = GetRepoListRequest.GetRepoListRequest()
# # response = apiClient.do_action(request)
# # repos = json.loads(response)
# # # print(repos)
# # data = {}
# # repositories = []
# # for name in repos.get('data').get('repos'):
# #     repositories.append(name.get('repoName'))
# # data["repositories"] = repositories
#
# request = GetRepoTagsRequest.GetRepoTagsRequest()
# request.set_RepoName("django1.11")
# request.set_RepoNamespace('uhongedu')
# response = apiClient.do_action(request)
# print(json.loads(response))
# l = int(request.GET.get('l','1'))
list = [0,1,2,7,4,5,6,3,10,9,8,6,'']
list.pop(-1)
j = 1  # 从后往前轮训的数
n = len(list)  # 列表的长度
num = 0  # 逆序数
for o in range(0,len(list)):
    for i in list[:-j]:
        m = list[n-1] # 轮训到某个数
        if i > m:
            num += 1
    j += 1
    n -= 1
    if j >= len(list):
        break
print '逆序数',num